package com.zr.action;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.zr.entity.ResultObj;
import com.zr.modelImpl.RecordModelImpl;

/**
 * Servlet implementation class GetAllMessageAction
 */
@WebServlet("/getAllMessage")
public class GetAllMessageAction extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//		HttpSession session = request.getSession();
//		String uid = (String) session.getAttribute("uid");
		String uid = "1001";
		String sender = request.getParameter("sender");
		System.out.println(sender);
		RecordModelImpl rmi = new RecordModelImpl();
		ResultObj robj = rmi.updateStatus(uid,sender);
		if(robj.isResult()) {
			robj = rmi.queryAllMessage(uid,sender);
		}
		String str = JSON.toJSONString(robj);
		response.getWriter().write(str);
		response.getWriter().close();
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		doGet(request, response);
	}

}
